package com.zy.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zy.business.domain.TbAbsence;
import com.zy.business.domain.vo.AbsenceDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface AbsenceMapper extends BaseMapper<TbAbsence> {

    TbAbsence getDetail(Long absenceId);

    @Select("select IFNULL(sum(absence_duration),0) from tb_absence where del_flag='0' and state=2 and apply_id=#{userId} and start_time >= #{startTime} and end_time <= #{endTime}")
    Double getDurationTotal(@Param("userId") Long userId, @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<TbAbsence> getUserList(@Param("userId") Long userId, @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<TbAbsence> selectListByTime(@Param("userId") Long userId, @Param("timeStr") String timeStr);

    List<TbAbsence> list(AbsenceDto absenceDto);

    Map<String, Object> getAbsenceData(@Param("userId") Long userId, @Param("type") Integer type);

}
